package com.lanou.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.lanou.entity.PageInfo;
import com.lanou.mapper.TopicMapper;
import com.lanou.service.TopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author 姚云鹏
 * Create at: 2018/6/21 16:48
 */
@Service
@Transactional(readOnly = true)
public class TopicServiceImpl implements TopicService {
    @Autowired
    private TopicMapper topicMapper;

    @Override
    public PageInfo list(PageInfo pageInfo, String sort, String order) {
        Page<Object> p = PageHelper.offsetPage(pageInfo.getOffset(),
                pageInfo.getLimit());

        topicMapper.findAll(sort,order);

        pageInfo.setRows(p.getResult());
        pageInfo.setTotal(p.getTotal());


        return pageInfo;
    }
}
